package kr.hkit.android_caloriecheck;

import kr.hkit.android_caloriecheck.fragment.DiaryFragment;
import kr.hkit.android_caloriecheck.fragment.ExerciseFragment;
import kr.hkit.android_caloriecheck.fragment.FoodFragment;
import kr.hkit.android_caloriecheck.fragment.HomeFragment;
import kr.hkit.android_caloriecheck.fragment.SettingFragment;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;

public class MainActivity extends Activity {
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		SharedPreferences pref = getSharedPreferences("user", 0);
		int height = pref.getInt("height", 0);
		
		if(height == 0){
			Intent intent = new Intent(MainActivity.this, IntroActivity.class);
			startActivity(intent);
			finish();
		}
						
		ActionBar actionBar = getActionBar();
		actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
		
		Tab tab = actionBar.newTab();
		tab.setText("홈");
		HomeFragment home = new HomeFragment();
		tab.setTabListener(new Tablistener(home, "home"));
		actionBar.addTab(tab);
		
		
		tab = actionBar.newTab();
		tab.setText("음식");
		FoodFragment food = new FoodFragment();
		tab.setTabListener(new Tablistener(food, "food"));
		actionBar.addTab(tab);
		
		
		tab = actionBar.newTab();
		tab.setText("운동");
		ExerciseFragment exercise = new ExerciseFragment();
		tab.setTabListener(new Tablistener(exercise, "exercise"));
		actionBar.addTab(tab);
		
		tab = actionBar.newTab();
		tab.setText("달력");
		DiaryFragment diary = new DiaryFragment();
		tab.setTabListener(new Tablistener(diary, "diary"));
		actionBar.addTab(tab);
		
		tab = actionBar.newTab();
		tab.setText("설정");
		SettingFragment settings = new SettingFragment();
		tab.setTabListener(new Tablistener(settings, "settings"));
		actionBar.addTab(tab);
		
		
	}
}
